function [alpha,beta,celltab]=alphabeta(MU,SD,dens,alper); 
% function [alpha,beta,celltab]=alphabeta(MU,SD,dens,alper); 
% Find alpha, beta to match the mean and standard deviation of
% Gamma if dens == 'G' 
% Beta  if dens == 'B'
% alpha is d degrees of freedom for IW 
% beta  is v scale parameter for IW 
% Note for GAMMA  & BETA can provide an column vector 
% of percentiles for which to find the values 
% If so, plot function not called and only those percentiles 
% reported. 
% Not valid with the IW 
% Modified 6/2/03 
if nargin < 4; 
    plotf = 1 ;
else 
    plotf = 0 ;
    m=length(alper); 
    cellone=num2cell(alper); 
end 
step=0.01; 
save=0; 
min=0.01; 
max=3; 
format rat; 
dens=upper(dens); 

if dens=='G'; 
    
    beta=(SD^2)/MU; 
    alpha=MU/beta; 
    
    if plotf == 1
        celltab=plotgamma(alpha,beta,[]);
    else 
        percent=gaminv(alper,alpha,beta);
        percent=num2cell(percent); 
        celltab=[cellone percent]; 
    end
    
elseif dens=='B'; 
    
    beta=MU*( (1-MU)^2 )/(SD^2) - ( 1 - MU );
    alpha=MU*beta/(1-MU); 
    
    if plotf == 1
       plotbeta(alpha,beta);
       celltab=[]; 
        
    else 
        %percent=betainv(alper,alpha,beta);
        %percent=num2cell(percent); 
        %celltab=[cellone percent]; 
       celltab=plotbeta(alpha,beta,info);
    end
    
elseif dens=='W' ; 
    
    alpha=2*(MU^2)/(SD^2) + 4; 
    beta=MU*(alpha-2);
    celltab=plotiw(alpha,beta,min,max,step,save); 
    
end
